<?php

namespace api\app\validate;

use think\Validate;

class DeliveryValidate extends Validate
{
    //定义验证规则
    protected $rule = [
        'username' => 'require|max:10',
        'mobile' => 'require|mobile',
        'address1'=>'require|max:30',
        'address2' => 'require|max:100'
    ];
    //定义验证失败时的提示信息
    protected $message = [
        'username.max:10' => '收货人名字过长',
        'mobile.require' => '手机号不能为空',
        'mobile.mobile' => '手机号类型错误',
        'address1.require' => '所在地区不能为空',
        'address1.max:30' => '所在地区最大长度为25',
        'address2.require' => '详细地址不能为空',
        'address2.max:100' => '地址最大长度为100',
    ];

    //验证场景
    protected  $scene = [
        'add' => ['username','mobile','address1','address2'],
        'edit' => ['username','mobile','address1','address2'],
    ];
}